﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using Chefbook.DataObjects;
using System.Globalization;
using Chefbook.DataAccessLayer;

namespace Chefbook.UserActions
{
    public class RenameCategoryAction : UserActionBase
    {
        private string oldName, newName;
        private Category categoryToRename;

        public RenameCategoryAction(Category categoryToRename, string newName)
        {
            this.categoryToRename = categoryToRename;
            this.oldName = categoryToRename.Name;
            this.newName = newName;
        }

        public override void DoAction()
        {
            base.DoAction();
            categoryToRename.Name = newName;
        }

        public override void UndoAction()
        {
            base.UndoAction();
            categoryToRename.Name = oldName;
        }

        public override string ToString()
        {
            return string.Format(CultureInfo.CurrentUICulture, "Rename Category from '{0}' to '{1}'", oldName, newName);
        }
    }
}
